Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Sort improve #246

Merged
merged 13 commits into from
Aug 4, 2021
Merged

Conversation

sundy-li
Copy link
Collaborator

@sundy-li sundy-li commented Aug 3, 2021

Related #245

Changes:

  • Add to_vec function to MergeSortSlices, this makes iterator reuseable.
  • Add buffer_from_range to Index trait
  • Fix some bad codes in benches.
  • Change cmp(a,b).reverse() to cmp(b,a)

@sundy-li
Copy link
Collaborator Author

sundy-li commented Aug 3, 2021

Seems #![feature(step_trait)] is not acceptable.

Without this trait, the performance reduces by 16%.

sort-limit 2^14 f32     time:   [53.572 us 53.758 us 53.967 us]                                
                        change: [+15.351% +16.099% +16.909%] (p = 0.00 < 0.05)
                        Performance has regressed.

Copy link
Owner

@jorgecarleitao jorgecarleitao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Left some comments around.

src/compute/sort/utf8.rs Outdated Show resolved Hide resolved
src/buffer/mutable.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/compute/sort/primitive/indices.rs Show resolved Hide resolved
@sundy-li
Copy link
Collaborator Author

sundy-li commented Aug 3, 2021

The only way currently I can find to reduce hot path from_usize().unwrap() is to add a method buffer_from_range in trait Index.

@sundy-li sundy-li requested a review from jorgecarleitao August 3, 2021 07:23
@codecov
Copy link

codecov bot commented Aug 3, 2021

Codecov Report

Merging #246 (22d58cf) into main (eea4d33) will decrease coverage by 0.12%.
The diff coverage is 52.32%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #246      +/-   ##
==========================================
- Coverage   76.81%   76.68%   -0.13%     
==========================================
  Files         229      229              
  Lines       19617    19675      +58     
==========================================
+ Hits        15068    15087      +19     
- Misses       4549     4588      +39     
Impacted Files Coverage Δ
src/array/specification.rs 41.97% <0.00%> (-30.37%) ⬇️
src/compute/sort/mod.rs 53.55% <0.00%> (ø)
src/compute/sort/utf8.rs 100.00% <ø> (ø)
src/compute/sort/boolean.rs 89.47% <50.00%> (-4.98%) ⬇️
src/buffer/mutable.rs 91.51% <75.00%> (-0.25%) ⬇️
src/compute/merge_sort/mod.rs 93.16% <88.46%> (-0.93%) ⬇️
src/compute/sort/common.rs 92.64% <91.66%> (-0.78%) ⬇️
src/compute/sort/lex_sort.rs 82.14% <100.00%> (+0.16%) ⬆️
src/compute/sort/primitive/indices.rs 100.00% <100.00%> (ø)
src/compute/sort/primitive/sort.rs 94.93% <100.00%> (+0.13%) ⬆️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eea4d33...22d58cf. Read the comment docs.

for (index, start, len) in self {
v.push((index, start, len));

if len + current_len >= limit {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this misses the last entries: if the last slice is past limit, imo it should be modified to be equal to limit - current_len, so that we do not lose the last items within the slice

@jorgecarleitao
Copy link
Owner

I can see that there is some limitations with stable Rust wrt to the ranges and indices. I will take a stab at addressing this here, to see if we can get the remaining performance out of this without the from_usize around.

@jorgecarleitao
Copy link
Owner

I think that #247 addresses the limitations; could you take a look and see what do you think?

@jorgecarleitao
Copy link
Owner

I have also created https://users.rust-lang.org/t/idiomatic-way-to-populate-vector-from-branched-loop/63152 to see if we get good ideas.

@sundy-li
Copy link
Collaborator Author

sundy-li commented Aug 4, 2021

Update:

Add shrink_to_fit() to fix #249

@sundy-li
Copy link
Collaborator Author

sundy-li commented Aug 4, 2021

I think that #247 addresses the limitations; could you take a look and see what do you think?

Ok, I'll take look at that.

@jorgecarleitao
Copy link
Owner

I will go ahead and merge this, and clear up the API in a follow-up PR. Thanks a lot, @sundy-li !

@jorgecarleitao jorgecarleitao merged commit 3d123b3 into jorgecarleitao:main Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants